/**
 * 无需身份验证的路由
 */
import {request} from "./request";

/**
 * 获取首页数据的网络请求
 * @returns {返回instance方法|发送网络请求}
 */
export function getIndexData() {
  return request({
    url: '/index',
    method: 'post',
  })
}

/***
 * 登录的网络请求
 * @param username
 * @param password
 * @returns {返回instance方法|发送网络请求}
 */
export const login = (username, password) => {
  let form = new FormData();
  form.append('username', username)
  form.append('password', password)

  return request({
    url: '/login',
    method: 'post',
    data: {
      username,
      password
    }
  })
}

/***
 * 注册的网络请求
 * @param username
 * @param password
 * @returns {返回instance方法|发送网络请求}
 */
export const register = (username, password) => {
  let form = new FormData()
  form.append('username', username)
  form.append('password', password)

  return request({
    url: '/register',
    method: 'post',
    data: {
      username,
      password
    }
  })
}

